﻿using DefCore.Mapping;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace DefCore.Structures
{
    public static class StructureFactory
    {
        public static T Create<T>(CellBase cell, StructureFrameEnum frame)
            where T : Structure
        {
            ConstructorInfo cinfo = typeof(T).GetConstructor(new Type[] { typeof(CellBase), typeof(StructureFrameEnum) });

            if (cinfo == null)
                return null;

            return (T)cinfo.Invoke(new object[] { cell, frame });
        }
    }

    public static class BlueprintFactory
    {
        public static T Create<T>()
               where T : Blueprint
        {
            ConstructorInfo cinfo = typeof(T).GetConstructor(new Type[] {  });

            if (cinfo == null)
                return null;

            return (T)cinfo.Invoke(new object[] { });
        }
        public static T Create<T>(BlueprintFrameAllowance allowance, Vector2 size)
            where T : Blueprint
        {
            ConstructorInfo cinfo = typeof(T).GetConstructor(new Type[] { typeof(BlueprintFrameAllowance), typeof(Vector2) });

            if (cinfo == null)
                return null;

            return (T)cinfo.Invoke(new object[] { allowance, size });
        }
    }
}
